if (qDebug && !originalEventRetriever->IsMemberClass(
GetClassIDFromName("TEventRetrieverCommand")))
ProgramBreak("First command in fEventList is not \
a TEventRetrieverCommand!");
To keep processing toolbox events at kPriorityLow, I declared a new command that is a descendant of TEventRetrieverCommand. This command checks for toolbox events but never sleeps. It is posted at kPriorityLow to replace the original TEventRetrieverCommand that was demoted to kPriorityLowest.
I put the declaration for TNoSleepEventRetrieverCommand in the header file that contains the declaration for TMyApplication.
I put the definitions for its methods in the .cp file that contains the methods of TMyApplication. The initialization method INoSleepEventRetrieverCommand() just calls IEventRetrieverCommand() and then sets the command's priority:
When IsReadyToExecute() returns true, MacApp calls the command’s DoIt() method. The DoIt() for TNoSleepEventRetrieverCommand is just like DoIt() for TEventRetrieverCommand except it calls PollToolboxEvent() with the parameter allowApplicationToSleep set to false so the application doesn’t go to sleep on us:
#pragma segment ASelCommand
pascal void TNoSleepEventRetrieverCommand::DoIt()
{
gApplication->PollToolboxEvent(FALSE);
// FALSE = never sleep
}
The TNoSleepEventRetrieverCommand is created and posted in TMyApplication after the priority of the original TEventRetrieverCommand is changed: